<template>
  <div>
    <div v-if="!repoUrl">loading</div>
    <div v-else>most star repo is <a :href="repoUrl">vue</a></div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'App',
  data () {
    return {
      repoUrl: '',
      repoName: ''
    }
  },
  mounted () {
    // 发请求
    const url = 'https://api.github.com/users/solomonxie/repos?page=2&per_page=3'
    axios.get(url).then(response => {
      console.log(response)
      const newVar = response.data[0].html_url
      const name = response.data[0].name
      this.repoUrl = newVar
      this.repoName = name
    }).catch(error => {
      alert(error)
    })
  }
}
</script>

<style scoped>

</style>
